<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<style>
	.tbl td {border-color: #797979}
	#tblconference td.banner {line-height: 30px; font-size: 18px; font-weight: bold; text-align: center; margin: 0;}
	#tblconference td.field {background-color: #CFDBEC; line-height: 25px; text-align: center; margin: 0; width: 100px; font-size: 9pt;}
	#tblconference input.textInput {float:none;margin: 5px; width: 80px; height: 23px;}
	#tblconference div.mf_container {width: 99%;}
</style>

<script>

	function refreshTotalFee (panel) {
		var conferenceFee = $("#feeEN", panel).val().replace(/(^\s*)|(\s*$)/g, "");
		var sponsFee = $("#ssEN", panel).val().replace(/(^\s*)|(\s*$)/g, "");
		var travelFee = $("#tfEN", panel).val().replace(/(^\s*)|(\s*$)/g, "");
		var totalFee = 0;
		if (conferenceFee != "" && !isNaN(conferenceFee)) {
			totalFee += parseFloat(conferenceFee);
		}
		if (sponsFee != "" && !isNaN(sponsFee)) {
			totalFee += parseFloat(sponsFee);
		}
		if (travelFee != "" && !isNaN(travelFee)) {
			totalFee += parseFloat(travelFee);
		}
		$("#totalFee", panel).val(totalFee);
		$("#ttCN", panel).html(Arabia_to_Chinese(totalFee+""));
	}

	$(function(){
		$.each($("textarea", $("#tblconference")), function(){
			$(this).html($(this).text().replace(/<br\/>/g,"\n"));
		});
		
		var current_panel = $.pdialog.getCurrent() && $.pdialog.getCurrent().filter(":visible").length > 0 ? $.pdialog.getCurrent() : navTab.getCurrentPanel();
		
		$('#conference_participants', current_panel).manifest({
			// Use each location's full name as the display text.
			formatDisplay: function (data, $item, $mpItem) {
				return data.username;
			},
			// Use each location's ID as the value to be submitted.
			formatValue: function (data, $value, $item, $mpItem) {
				return data.id;
			},
			<logic:present name="attendees">
			values: eval(${projectAttendees}),
			</logic:present>
			valuesName: 'conferenceAttendeeIds',
			<c:choose>
				<c:when test="${op ne null && op eq 'view' || op eq 'audit' || op eq 'audit' || op eq 'post_stuff'}">
					readonly: true,
				</c:when>
				<c:otherwise>
					marcoPolo: {
						url: 'app/base.do?action=lookupUserByName',
						formatItem: function (data) {
						  return '"' + data.username + '" (' + data.userNo + ')';
						},
						param: 'search'
					}
				</c:otherwise>
			</c:choose>
		});
		
		$("#feeEN", current_panel).keyup(function(){
			$("#feeCN", current_panel).html(Arabia_to_Chinese(this.value));
			refreshTotalFee(current_panel);
		});
		
		$("#ssEN", current_panel).keyup(function(){
			$("#ssCN", current_panel).html(Arabia_to_Chinese(this.value));
			refreshTotalFee(current_panel);
		});
		
		$("#tfEN", current_panel).keyup(function(){
			$("#tfCN", current_panel).html(Arabia_to_Chinese(this.value));
			refreshTotalFee(current_panel);
		});
		
		<logic:present name="entity">
			$("#feeCN",current_panel).html(Arabia_to_Chinese("${entity.fee}"));
			$("#ssCN", current_panel).html(Arabia_to_Chinese("${entity.sponsorship}"));
			$("#tfCN", current_panel).html(Arabia_to_Chinese("${entity.travelFee}"));
			$("#ttCN", current_panel).html(Arabia_to_Chinese("${entity.fee + entity.sponsorship + entity.travelFee}"));
		</logic:present>
	});
</script>

<div class="pageFormContent">
	<div align="right" style="margin-bottom: 15px; margin-right: 20px;">
		<table cellpadding="0" cellspacing="0" style="border-bottom: 1px solid #999; padding-bottom: 10px;">
			<tr>
				<td width="95px" align="center">填表时间</td>
				<td>
					<input class="${op ne null && (op eq 'view' || op eq 'audit') ? '' : 'required'} textInput ${op ne null && op eq 'view' || op eq 'audit' ? '' : 'date'}" name="applyTime" 
						value="<fmt:formatDate value='${applyTime}' type='date' pattern='yyyy-MM-dd'/>" error_message="请填写`申请时间`" type="text" style="width: 98%;" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
				</td>
			</tr>
		</table>
	</div>
	
	<table class="tbl" id="tblconference" cellpadding="0" cellspacing="0" width="97%" border="1" style="border-collapse: collapse; border-color: #797979; margin: 0 auto;" rules="all">
		<tr>
			<td class='field'>申请人</td>
			<td style="text-align:center">${entity ne null ? entity.applicant.username : (account ne null ? account.username : '')}</td>
			<td class='field'>职务</td>
			<td style="text-align:center">${profile ne null && profile.jobTitle ne null ? profile.jobTitle.dictKey : ''}</td>
			<td class='field'>参会时间</td>
			<td>
				<input name="time" class="${op ne null && op eq 'view' || op eq 'audit' ? '' : 'date'} textInput ${op ne null && (op eq 'view' || op eq 'audit') ? '' : 'required'}" 
					yearstart="-80" yearend="0" datefmt="yyyy-MM-dd" style="width: 96%;" value="<c:if test='${entity ne null}'><fmt:formatDate value='${entity.time}' type='date' pattern='yyyy-MM-dd'/></c:if>" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
			</td>
		</tr>
		<tr>
			<td class='field'>会议名称</td>
			<td colspan='3'>
				<input name="title" class="textInput ${op ne null && (op eq 'view' || op eq 'audit') ? '' : 'required'}" value="${entity ne null ? entity.title : ''}" type="text" 
					style="width: 93%;" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
			</td>
			<td class='field'>参会地点</td>
			<td>
				<input name="place" class="textInput ${op ne null && (op eq 'view' || op eq 'audit') ? '' : 'required'}" value="${entity ne null ? entity.place : ''}" type="text" 
					style="width: 96%;" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
			</td>
		</tr>
		<tr>
			<td class='field'>参会人员</td>
			<td colspan='5' style='padding: 5px;'>
				<input id="conference_participants" name="conferenceAttendeeIds" class="textInput" value="" type="text" 
					style="width: 92%;" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
			</td>
		</tr>
		<tr>
			<td class='field'>会议简介</td>
			<td colspan='3'>
				<input name="introduction" class="textInput ${op ne null && (op eq 'view' || op eq 'audit') ? '' : 'required'}" value="${entity ne null ? entity.introduction : ''}" type="text" 
					style="width: 93%;" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
			</td>
			<td class='field'>申请理由</td>
			<td>
				<input name="reason" class="textInput" value="${entity ne null ? entity.reason : ''}" type="text" 
					style="width: 96%;" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
			</td>
		</tr>
		<tr>
			<td class='field'>会务费</td>
			<td colspan='3'>
				<input id="feeEN" name="fee" class="textInput" value="${entity ne null ? entity.fee : ''}" type="text" 
					style="width: 93%;" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
			</td>
			<td class='field'>大写</td>
			<td id="feeCN" style="padding-left: 5px;"></td>
		</tr>
		<tr>
			<td class='field'>赞助费</td>
			<td colspan='3'>
				<input id="ssEN" name="sponsorship" class="textInput" value="${entity ne null ? entity.sponsorship : ''}" type="text" 
					style="width: 93%;" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
			</td>
			<td class='field'>大写</td>
			<td id="ssCN" style="padding-left: 5px;"></td>
		</tr>
		<tr>
			<td class='field'>差旅费</td>
			<td colspan='3'>
				<input id="tfEN" name="travelFee" class="textInput" value="${entity ne null ? entity.travelFee : ''}" type="text" 
					style="width: 93%;" ${op ne null && op eq 'view' || op eq 'audit' ? 'readonly' : ''}/>
			</td>
			<td class='field'>大写</td>
			<td id="tfCN" style="padding-left: 5px;"></td>
		</tr>
		<tr>
			<td class='field'>总计</td>
			<td colspan='3'>
				<input id="totalFee" value="${entity ne null ? entity.totalFee : ''}" class="textInput" type="text" style="width: 93%;" readonly />
			</td>
			<td class='field'>大写</td>
			<td id="ttCN" style="padding-left: 5px;"></td>
		</tr>
		<c:if test="${entity ne null}">
			<tr>
				<td class='field'>部门负责人<br/>审批意见</td>
				<td colspan="5">
					<textarea name="deptMeto" rows="2" style="width: 97.5%; height: 35px; margin: 5px;" readonly>${entity ne null ? entity.deptMeto : ''}</textarea>
				</td>
			</tr>
			<tr>
				<td class='field'>院领导<br/>审批意见</td>
				<td colspan="5">
					<textarea name="leadershipMeto" rows="2" style="width: 97.5%; height: 35px; margin: 5px;" readonly>${entity ne null ? entity.leadershipMeto : ''}</textarea>
				</td>
			</tr>
		</c:if>
		<c:if test="${entity ne null}">
			<tr>
				<td class='field' style="background-color:#999" rowspan="${fn:length(entity.events)}">会议进展记录</td>
				<logic:present name="entity" property="events">
					<logic:iterate name="entity" property="events" length="1" id="event">
						<td style="text-align:center;line-height: 25px;background-color:#CCCCCC">${event.eventName}</td>
						<td style="text-align:center">${event.eventOperator ne null ? event.eventOperator.username : '---'}</td>
						<td style="text-align:center"><fmt:formatDate value='${event.eventTime}' type='date' pattern='yyyy-MM-dd HH:mm'/></td>
						<td style="text-align:left; padding-left: 5px;" colspan="2">
							<c:choose>
								<c:when test="${event.eventState ne null && event.eventState ne 0}">
									<c:choose>
										<c:when test="${event.eventState ne null && event.eventState eq 1}">通过</c:when>
										<c:when test="${event.eventState ne null && event.eventState eq -1}">退回</c:when>
										<c:when test="${event.eventState ne null && event.eventState eq 2}">否决</c:when>
									</c:choose>
									<c:if test="${event.eventComments ne null && event.eventComments ne ''}"> (审核意见：${event.eventComments})</c:if>
								</c:when>
								<c:otherwise>
									<c:if test="${event.eventComments ne ''}"> ${event.eventComments}</c:if>
								</c:otherwise>
							</c:choose>
						</td>
					</logic:iterate>
				</logic:present>
			</tr>
			<logic:present name="entity" property="events">
				<logic:iterate name="entity" property="events" offset="1" id="event">
					<tr>
						<td style="text-align:center;line-height: 25px;background-color:#CCCCCC">${event.eventName}</td>
						<td style="text-align:center">${event.eventOperator ne null ? event.eventOperator.username : '---'}</td>
						<td style="text-align:center"><fmt:formatDate value='${event.eventTime}' type='date' pattern='yyyy-MM-dd HH:mm'/></td>
						<td style="text-align:left; padding-left: 5px;" colspan="2">
							<c:choose>
								<c:when test="${event.eventState ne null && event.eventState ne 0}">
									<c:choose>
										<c:when test="${event.eventState ne null && event.eventState eq 1}">通过</c:when>
										<c:when test="${event.eventState ne null && event.eventState eq -1}">退回</c:when>
										<c:when test="${event.eventState ne null && event.eventState eq 2}">否决</c:when>
									</c:choose>
									<c:if test="${event.eventComments ne null && event.eventComments ne ''}"> (审核意见：${event.eventComments})</c:if>
								</c:when>
								<c:otherwise>
									<c:if test="${event.eventComments ne ''}"> ${event.eventComments}</c:if>
								</c:otherwise>
							</c:choose>
						</td>
					</tr>
				</logic:iterate>
			</logic:present>
		</c:if>
	</table>
</div>
<input type="hidden" name="id" value="${entity ne null ? entity.id : -1}" />
<input type="hidden" name="op" value="${op ne null && op ne '' ? op : ''}" />
<input type="hidden" name="uid" value="${entity ne null && entity.applicant ne null ? entity.applicant.id : (account ne null ? account.id : -1)}" />